package com.example.consumer.config;

import com.rabbitmq.client.AMQP;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TopicConfig {
    public static final String XIAOMI_QUEUE = "xiaomi_queue_name";
    public static final String IPHONE_QUEUE = "iphone_queue_name";
    public static final String HUAWEI_QUEUE = "huawei_queue_name";

    public static final String TOPIC_EXCHANGE_NAME = "topic_exchange_name";

    @Bean
    Queue xiaomiQueue(){
        return new Queue(XIAOMI_QUEUE,true,false,false);
    }
    @Bean
    Queue iphoneQueue(){
        return new Queue(IPHONE_QUEUE,true,false,false);
    }
    @Bean
    Queue huaweiQueue(){
        return new Queue(HUAWEI_QUEUE,true,false,false);
    }

    @Bean
    TopicExchange topicExchange(){
        return new TopicExchange(TOPIC_EXCHANGE_NAME,true,false);
    }

    @Bean
    Binding xiaomiBind(){
        return BindingBuilder.bind(xiaomiQueue()).to(topicExchange()).with("xiaomi.#");
    }
    @Bean
    Binding huaweiBind(){
        return BindingBuilder.bind(huaweiQueue()).to(topicExchange()).with("huawei.#");
    }
    @Bean
    Binding iphoneBind(){
        return BindingBuilder.bind(iphoneQueue()).to(topicExchange()).with("#.phone.#");
    }
}
